﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using MModel;
using System.Data.SqlClient;
namespace DAL
{
    public class sdal
    {
        string station = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
     
        //登录
        public int deng(denglu lu)
      
        {
            string tar = string.Format("select count(*)from denglu where dname='{0}'and dpwd='{1}'", lu.dname, lu.dpwd);
            SqlConnection con = new SqlConnection(station);
            SqlCommand mand = new SqlCommand(tar, con);
    
            con.Open();
            int i =Convert.ToInt32( mand.ExecuteScalar());
            con.Close();
            return i;

        }

        //显示学生信息
        public List<sheng> xue()
        {
            string tar = "select* from sheng";
            SqlConnection con = new SqlConnection(station);
            SqlCommand mand = new SqlCommand(tar, con);
            con.Open();
            SqlDataReader reader = mand.ExecuteReader();
            List<sheng>she=new List<sheng>();
            while (reader.Read())
            {
                sheng sh = new sheng();
                sh.sid = Convert.ToInt32(reader["sid"]);
                sh.sname = reader["sname"].ToString();
                sh.sex = reader["sex"].ToString();
                sh.tell = reader["tell"].ToString();
                sh.addr = reader["addr"].ToString();
                sh.sban = reader["sban"].ToString();
                sh.likes = reader["likes"].ToString();
                sh.height = reader["height"].ToString();
                sh.bad = reader["bad"].ToString();
                she.Add(sh);
            }
            con.Close();
            return she;

        
        
        }


    }
}
